package com.iplant.ams.service.po.dms.scada.conf;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.iplant.ams.service.basicenum.dms.scada.DMSDataActions;
import com.iplant.ams.service.basicenum.dms.scada.DMSDataClass;
import com.iplant.ams.service.basicenum.dms.scada.DMSDataTypes;
import com.iplant.base.po.BasePO;
import com.iplant.base.po.enums.DBSchemas;
import com.iplant.base.utils.annotation.condition.DBCondition;
import com.iplant.base.utils.annotation.field.DBField;
import com.iplant.base.utils.annotation.join.DBJoin;
import com.iplant.base.utils.annotation.po.DBBasePO;

import java.io.Serializable;

@DBBasePO(TableName = "dms_device_parameter", Schemas = DBSchemas.AMS,
        CheckName = {"Code", "DeviceID,DataClass,VariableName", "AssetNo,DataClass,VariableName",
                "DeviceID,DataClass,Name", "AssetNo,DataClass,Name"},
        CodeAuto = true,CodePrefix = "{:AssetNo}{:DataClass}",CodeNum = 4
)
public class DMSDeviceParameter extends BasePO implements Serializable {

    /**
     * 变量名称
     */
    @DBCondition
    @DBField
    public String VariableName = "";

    /**
     * 设备ID
     */
    @DBCondition
    @DBField
    public int DeviceID = 0;

    /**
     * 固定编号
     */
    @DBCondition
    @DBField
    public String AssetNo = "";

    /**
     * 资产ID
     */
    @DBCondition
    @DBField
    public int AssetInfoID = 0;


    /**
     * 设备名称
     **/
    @DBJoin(name = "Name", tableName = "ams_asset_list", tableAsName = "ams_asset_list1", Schemas = DBSchemas.AMS,
            JoinIndex = 2,
            MainTableField = "AssetInfoID")
    public String DeviceName = "";
    /**
     * 设备编码
     **/
    @DBCondition
    @DBJoin(name = "Code", tableName = "ams_asset_list", tableAsName = "ams_asset_list1", Schemas = DBSchemas.AMS,
            JoinIndex = 2,
            ConditionalJoin = "AssetInfoID")
    public String DeviceCode = "";




    /**
     * 服务ID
     */
    @DBCondition
    @DBField
    public int ServerId = 0;

    @DBJoin(name ="ServerName",tableName = "dms_device_server", tableAsName = "sever1",MainTableField = "ServerId",Schemas = DBSchemas.AMS)
    public String ServerName = "";


    /**
     * 通讯协议
     */
    @DBField
    public String Protocol = "";

    /**
     * 标签地址
     */
    @DBField
    public String OPCClass = "";
    /**
     * 数据类型
     */
    @DBCondition
    @DBField
    public int DataType = 0;

    public String DataTypeText = "";

    /**
     * 数据分类
     */
    @DBCondition
    @DBField
    public int DataClass = 0;

    public String DataClassText = "";

    /**
     * 数据采集模式
     */
    @DBCondition
    @DBField
    public int DataAction = 0;

    public String DataActionText = "";


    @DBField
    public int InternalTime = 0;

    /**
     * 数据长度 0不显示   datatype为字符串时使用
     */

    @DBField
    public int DataLength = 0;

    /**
     * 等级  用于配置报警等级
     */
    @DBCondition
    @DBField
    public int DataGrad = 0;




    /**
     * 字符主键   用于数据分组  一级组
     */
    @DBCondition
    @DBField
    public String KeyChar = "";

    /**
     * 字符辅键  用于数据分组  二级组
     */
    @DBCondition
    @DBField
    public String AuxiliaryChar = "";


    /**
     * 上限值
     */
    @DBField
    public double ValueRight = 0.0f;


    /**
     * 下限值
     */
    @DBField
    public double ValueLeft = 0.0f;

    /**
     * 分析顺序
     */
    @DBField
    public int AnalysisOrder = 0;

    /**
     * 合并实际顺序
     */
    @DBField
    public int ActOrder = 0;

    /**
     * 反转Bool
     */
    @DBField
    public int Reversed = 0;

    /**
     * 位置ID  一般用于报警信息
     */
    @DBField
    public int PositionID = 0;

    /**
     * 位置名称
     */
    @DBJoin(name = "Name", tableName = "dms_position", tableAsName = "dp1", MainTableField = "PositionID",Schemas = DBSchemas.AMS)
    public String PositionName = "";

    @DBField(name = "ParameterDesc")
    public String Description = "";
    @JsonProperty("DeviceID")
    public int getDeviceID() {
        return DeviceID;
    }

    public void setDeviceID(int deviceID) {
        DeviceID = deviceID;
    }

    @JsonProperty("AssetNo")
    public String getAssetNo() {
        return AssetNo;
    }

    public void setAssetNo(String assetNo) {
        AssetNo = assetNo;
    }

    @JsonProperty("AssetInfoID")
    public int getAssetInfoID() {
        return AssetInfoID;
    }

    public void setAssetInfoID(int assetInfoID) {
        AssetInfoID = assetInfoID;
    }

    @JsonProperty("DeviceName")
    public String getDeviceName() {
        return DeviceName;
    }

    public void setDeviceName(String deviceName) {
        DeviceName = deviceName;
    }

    @JsonProperty("DeviceCode")
    public String getDeviceCode() {
        return DeviceCode;
    }

    public void setDeviceCode(String deviceCode) {
        DeviceCode = deviceCode;
    }

    @JsonProperty("VariableName")
    public String getVariableName() {
        return VariableName;
    }

    public void setVariableName(String variableName) {
        VariableName = variableName;
    }

    @JsonProperty("ServerId")
    public int getServerId() {
        return ServerId;
    }

    public void setServerId(int serverId) {
        ServerId = serverId;
    }

    @JsonProperty("ServerName")
    public String getServerName() {
        return ServerName;
    }

    public void setServerName(String serverName) {
        ServerName = serverName;
    }

    @JsonProperty("Protocol")
    public String getProtocol() {
        return Protocol;
    }

    public void setProtocol(String protocol) {
        Protocol = protocol;
    }

    @JsonProperty("OPCClass")
    public String getOPCClass() {
        return OPCClass;
    }

    public void setOPCClass(String OPCClass) {
        this.OPCClass = OPCClass;
    }

    @JsonProperty("DataType")
    public int getDataType() {
        return DataType;
    }

    public void setDataType(int dataType) {
        DataType = dataType;
    }

    @JsonProperty("DataTypeText")
    public String getDataTypeText() {
        DataTypeText= DMSDataTypes.getEnumType(DataType).getLabel();

        return DataTypeText;
    }

    public void setDataTypeText(String dataTypeText) {
        DataTypeText = dataTypeText;
    }

    @JsonProperty("DataClass")
    public int getDataClass() {
        return DataClass;
    }

    public void setDataClass(int dataClass) {
        DataClass = dataClass;
    }

    @JsonProperty("DataClassText")
    public String getDataClassText() {

        DataClassText= DMSDataClass.getEnumType(DataClass).getLabel();
        return DataClassText;
    }

    public void setDataClassText(String dataClassText) {
        DataClassText = dataClassText;
    }

    @JsonProperty("DataAction")
    public int getDataAction() {
        return DataAction;
    }

    public void setDataAction(int dataAction) {
        DataAction = dataAction;
    }

    @JsonProperty("DataActionText")
    public String getDataActionText() {
        DataActionText= DMSDataActions.getEnumType(DataAction).getLabel();
        return DataActionText;
    }

    public void setDataActionText(String dataActionText) {
        DataActionText = dataActionText;
    }

    @JsonProperty("InternalTime")
    public int getInternalTime() {
        return InternalTime;
    }

    public void setInternalTime(int internalTime) {
        InternalTime = internalTime;
    }

    @JsonProperty("DataLength")
    public int getDataLength() {
        return DataLength;
    }

    public void setDataLength(int dataLength) {
        DataLength = dataLength;
    }

    @JsonProperty("KeyChar")
    public String getKeyChar() {
        return KeyChar;
    }

    public void setKeyChar(String keyChar) {
        KeyChar = keyChar;
    }

    @JsonProperty("AuxiliaryChar")
    public String getAuxiliaryChar() {
        return AuxiliaryChar;
    }

    public void setAuxiliaryChar(String auxiliaryChar) {
        AuxiliaryChar = auxiliaryChar;
    }

    @JsonProperty("ValueRight")
    public double getValueRight() {
        return ValueRight;
    }

    public void setValueRight(double valueRight) {
        ValueRight = valueRight;
    }

    @JsonProperty("ValueLeft")
    public double getValueLeft() {
        return ValueLeft;
    }

    public void setValueLeft(double valueLeft) {
        ValueLeft = valueLeft;
    }

    @JsonProperty("AnalysisOrder")
    public int getAnalysisOrder() {
        return AnalysisOrder;
    }

    public void setAnalysisOrder(int analysisOrder) {
        AnalysisOrder = analysisOrder;
    }

    @JsonProperty("ActOrder")
    public int getActOrder() {
        return ActOrder;
    }

    public void setActOrder(int actOrder) {
        ActOrder = actOrder;
    }

    @JsonProperty("Reversed")
    public int getReversed() {
        return Reversed;
    }

    public void setReversed(int reversed) {
        Reversed = reversed;
    }

    @JsonProperty("PositionID")
    public int getPositionID() {
        return PositionID;
    }

    public void setPositionID(int positionID) {
        PositionID = positionID;
    }

    @JsonProperty("PositionName")
    public String getPositionName() {
        return PositionName;
    }

    public void setPositionName(String positionName) {
        PositionName = positionName;
    }


    @JsonProperty("DataGrad")
    public int getDataGrad() {
        return DataGrad;
    }

    public void setDataGrad(int dataGrad) {
        DataGrad = dataGrad;
    }
    @JsonProperty("Description")
    @Override
    public String getDescription() {
        return Description;
    }

    @Override
    public void setDescription(String description) {
        Description = description;
    }
}
